﻿Imports System.Reflection

''' <summary>
''' 追加ダーティオブジェクト
''' </summary>
''' <remarks>
''' 追加されたオブジェクトを示すクラス
''' </remarks>
Public Class AddDirtyObject
    Inherits DirtyObject

    ''' <summary>
    ''' コンストラクタ
    ''' </summary>
    ''' <param name="instance"></param>
    ''' <remarks></remarks>
    Public Sub New(instance As Object, instanceType As Type)
        Me.Key = KeyGenerator.Generate(instance)
        Me.Instance = instance
        Me.InstanceType = instanceType
    End Sub

    Private _instance As Object
    ''' <summary>
    ''' 現在のインスタンス
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Instance As Object
        Get
            Return _instance
        End Get
        Private Set(ByVal value As Object)
            _instance = value
        End Set
    End Property

    ''' <summary>
    ''' ダーティタイプ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides ReadOnly Property DirtyType As DirtyTypes
        Get
            Return DirtyTypes.Add
        End Get
    End Property

    ''' <summary>
    ''' ダーティプロパティ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides ReadOnly Property DirtyProperties As IEnumerable(Of LiteralProperty)
        Get
            '追加ダーティの場合、全て
            Dim def = Me.InstanceType.ToEntityDefinition
            Dim q = (From el In def.LiteralProperties)
            Return q
        End Get
    End Property
End Class
